import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/components/Home/Home.vue'

// 挂载路由   ==> Vue.propotype.$router = Router;
Vue.use(Router)

export default new Router({
  // 给所有的router-link添加一个被激活的类名
  linkActiveClass: 'link-active',
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'home',
      component: (resolve) => require(['@/components/Home/Home'], resolve),
      meta: {
        tite: '首页'
      }
    }, {
      path: '/vip',
      name: 'vip',
      component: (resolve) => require(['@/components/Vip/Vip'], resolve),
      meta: {
        tite: '会员'
      }
    }, {
      path: '/cart',
      name: 'cart',
      component: (resolve) => require(['@/components/Cart/Cart'], resolve),
      meta: {
        tite: '购物车'
      }
    }, {
      path: '/search',
      name: 'search',
      component: (resolve) => require(['@/components/Search/Search'], resolve),
      meta: {
        tite: '搜索'
      }
    }, {
      path: '/news',
      name: 'news',
      component: (resolve) => require(['@/components/News/NewsList'], resolve),
      meta: {
        tite: '新闻列表'
      }
    }, {
      path: '/news/detail',
      name: 'news-detail',
      component: (resolve) => require(['@/components/News/NewsDetail'], resolve),
      meta: {
        tite: '新闻详情'
      }
    }, {
      // 动态路由规则
      path: '/photos/:categoryId',
      name: 'photos',
      component: (resolve) => require(['@/components/photo/Photos'], resolve),
      meta: {
        tite: '图文分享'
      }
    },{
      path: '/photos/detail',
      name: 'photo-detail',
      component: (resolve) => require(['@/components/photo/PhotoDetail'], resolve),
      meta: {
        tite: '图文分享'
      }
    }]
})
